//
//  ZYXNavigationController.m
//  Lottery
//  自定义导航控制器
//

#import "ZYXNavigationController.h"

@interface ZYXNavigationController ()

@end

@implementation ZYXNavigationController


/**
 *  系统在第一次使用这个类的时候调用该类方法initialize
 */
+(void)initialize
{
    //设置导航栏主题图片
    UINavigationBar *navBar = [UINavigationBar appearance];
    if (iOS7) {
        [navBar setBackgroundImage:[UIImage imageNamed:@"NavBar64"] forBarMetrics:UIBarMetricsDefault];
    }else{
        [navBar setBackgroundImage:[UIImage imageNamed:@"NavBar"] forBarMetrics:UIBarMetricsDefault];
    }
    
    //设置导航栏字体颜色
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    
    //iOS7已过期
    //attrs[UITextAttributeTextColor] = [UIColor whiteColor];
    //attrs[UITextAttributeFont]      = [UIFont systemFontOfSize:17];
    
    attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:18];
    
    //attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
    [navBar setTitleTextAttributes:attrs];
}


/**
 *  导航控制器push子控制器到导航控制器栈的栈顶
 *
 *  @param viewController 子控制器
 *  @param animated       动画
 */
-(void) pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    //拦截导航控制器子控制器的push过程
    //NSLog(@"%@",viewController);
    viewController.hidesBottomBarWhenPushed = YES;
    
    //把新添加的导航控制器的子控制器push到导航控制器子控制器栈的栈顶
    [super pushViewController:viewController animated:animated];
    //取消push进子控制器的动画效果
    //[super pushViewController:viewController animated:NO];
}


/**
 *  弹出导航控制器的子控制器
 *
 *  @param animated 动画
 *
 *  @return 弹出的子控制器
 */
-(UIViewController *)popViewControllerAnimated:(BOOL)animated
{
    //NSLog(@"%@",[super popViewControllerAnimated:animated]);
    //animated = NO;
    return [super popViewControllerAnimated:animated];
}

@end
